Leadtools.Dicom.Common
LEAD Technologies, Inc

MacroProcessor<T> Class

Example 





Members 
Type of data passed to the macro substitution delegates.
Manages the processing of macros.
Object Model
MacroProcessor<T> Class
Syntax
public class MacroProcessor<T> 
'Declaration
 
Public Class MacroProcessor(Of T) 
'Usage
 
Dim instance As MacroProcessor(Of T)
public sealed class MacroProcessor<T> 
function Leadtools.Dicom.Common.Anonymization.MacroProcessor()
generic<typename T>
public ref class MacroProcessor 
Type Parameters
T
Type of data passed to the macro substitution delegates.
Remarks
Macros are defined as ${macro_name} in strings. This class looks for those tokens and calls the appropriate registered delegate to return a string. The MacroProcessor class has the following default macros when created:
Value Meaning
date Current date.
random_string Random string of specified link.
random_date Random date in the specified min/max date range.
empty Empty string.
random_time Random time offset from the specified time.
Example
Copy CodeCopy Code  
Public Sub MacroProcessorSample()
   Dim processor As New MacroProcessor(Of Object)()

   '
   ' add two macros to the macro processor
   '
   processor.Macros.Add("current_date", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentDateMacro))
   processor.Macros.Add("current_time", New MacroSubsitutionDelegate(Of Object)(AddressOf CurrentTimeMacro))

   '
   ' Process a macro string
   '
   Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}"))
End Sub

Private Function CurrentDateMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String
   Return DateTime.Now.ToShortDateString()
End Function

Private Function CurrentTimeMacro(ByVal userData As Object, ByVal name As String, ByVal ParamArray parameters As Object()) As String
   Return DateTime.Now.ToShortTimeString()
End Function
public void MacroProcessorSample()
{
   MacroProcessor<object> processor = new MacroProcessor<object>();

   //
   // add two macros to the macro processor
   //

   processor.Macros.Add("current_date", new MacroSubsitutionDelegate<object>(CurrentDateMacro));
   processor.Macros.Add("current_time", new MacroSubsitutionDelegate<object>(CurrentTimeMacro));

   //
   // Process a macro string
   //

   Console.WriteLine(processor.Process(processor, "${current_date} ==> ${current_time}"));
}

private string CurrentDateMacro(object userData, string name, params object[] parameters)
{
   return DateTime.Now.ToShortDateString();
}

private string CurrentTimeMacro(object userData, string name, params object[] parameters)
{
   return DateTime.Now.ToShortTimeString();
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

MacroProcessor<T> Members
Leadtools.Dicom.Common.Anonymization Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Dicom.Common requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features